package main

import (
	"center/appmgr"
	"os"
	"os/signal"
	"util/log"
)

func main() {
	config := appmgr.CreateConfig()
	if !config.Load() {
		log.LogError("load config failed")
		return
	}

	appbook := appmgr.NewAppSvr(config.SvrIp, config.SvrPort)
	if !appbook.Start() {
		log.LogError("start appbook failed")
		return
	}

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)
	go func() {
		select {
		case <-c:
			appbook.Stop()
			log.TraceInfo("center", "stop service")
		}
	}()

	appbook.Done()
}
